﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace CSUnitTest
{
    /// <summary>
    /// pdm 的摘要说明
    /// </summary>
    [TestClass]
    public class pdm
    {

        [TestMethod]
        public void TestMethod1()
        {
            //通过物料编码获取 ERP 中的价格数据
            //<param name="materialNumbers”>物料编码。</param>
            //[TestMethod]
            //public List<string> GetMaterialPrices(IEnumerable<string> materialNumbers = null)
            //{
            //    using (var mgr = ConstValue.GetCommand(provider))
            //    using (var cmd = mgr.Connection.CreateCommand())
            //    {
            //        try
            //        {
            //            var sql = "SELECT FNUMBER FROM CVIEW PDM JGK";
            //            //var sql = "SELECT FNUMBER,Date FROM CVIEW_PDM_JGK";
            //            if (materialNumbers != null && materialNumbers.Any())
            //            {
            //                sql += string.Format("WHERE FNUMBER IN({0})",
            //                    string.Join(",", materialNumbers.Take(1000).Select(_ => string.Format("'{0}'", _))));
            //                int i = 1;
            //                do
            //                {
            //                    var materialNumbersOfSection = materialNumbers.Skip(i++ * 1000).Take(1000);
            //                    if (materialNumbersOfSection.Count() == 0) break;
            //                    sql += string.Format("OR FNUMBER IN({O})",
            //                        string.Join(",", materialNumbersOfSection.Select(_ => string.Format("'{0}'", _))));
            //                } while (true);
            //            }
            //            cmd.CommandText = sql;
            //            using (var reader = cmd.ExecuteReader())
            //            {
            //                while (reader.Read())
            //                {
            //                    string fnumber = reader.GetString(reader.GetOrdinal("FNUMBER"));
            //                    DateTime fdate = reader.GetDateTime(reader.GetOrdinal("date"));

            //                }
            //            }
            //            //return ConstValue.DataReaderToDataTable(cmd.ExecuteReader())
            //            //    .AsEnumerable()
            //            //    .Select(_ => _.Field<string>("FNUMBER")).ToList();
            //        }
            //        catch (Exception e)
            //        {
            //            Logger.Error(e);
            //        }
            //    }

            //    return new List<string>();
            //}


            //return ConstValue.DataReaderToDataTable(cmd.ExecuteReader())
            //                .AsEnumerable()
            //                .Select(_ => _.Field<string>("FNUMBER")).ToList();
        }
    }
}
